package com.zhiyou.Util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisUtil {

    public static SqlSessionFactory getSqlSessionFactory() {
        String resource = "mybatis-config.xml";//配置文件的名字
        SqlSessionFactory factory=null;
        try {
            InputStream is = Resources.getResourceAsStream(resource);//获取配置文件的输入流
            factory = new SqlSessionFactoryBuilder().build(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return factory;
    }
}
